Desktop.ApplicationLauncher = function (_appName, _iconPath) {
    var appName = _appName || "Window";
    var iconPath = _iconPath || "Path to default icon";
    this.getAppName = function () {
        return appName;
    }

    this.getIconPath = function () {
        return iconPath;
    }
}

Desktop.ApplicationLauncher.prototype.renderIcon = function ($taskBar) {
    // Create the icon and add it to the DOM-Structure.
    var elementToCreate = '<a name="' + this.getAppName() + '" href="#"><img src=' + this.getIconPath() + ' class="icon"/></a>';
    $(elementToCreate).appendTo($taskBar);

    // Create a click event.
    this.createClickEvent(this.getAppName());
}

Desktop.ApplicationLauncher.prototype.createClickEvent = function (applicationName) {
    var selector = 'a[name="' + applicationName + '"]';
    var that = this;
    $(selector).click(function (e) { that.onClick(e) });
}

Desktop.ApplicationLauncher.prototype.onClick = function (e) {
    e = e || event;

    // Create the new Window.
    var window = new Desktop.Window($('#desktopWindow')[0], this.getIconPath(), this.getAppName());

    // Add that we opened a new window.
    Desktop.addOpenWindow();
}